﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ConfigManager.ChildForms;
using ComLib.ConfigService;
using ProcessConfig.ConfigType;
using ProcessConfig;
using ComLib.ComType;

namespace ConfigManager.TabPages
{
    public partial class TabPageApplyOption : TabPageBase
    {
        private Dictionary<ApplyTo, string> DicPxlPaths = new Dictionary<ApplyTo, string>();

        private void InitDic()
        {
            DicPxlPaths.Add(ApplyTo.ExitAndEntry, "epassport_ys");
            DicPxlPaths.Add(ApplyTo.IDCard, "epassport_ys_sfz");
            DicPxlPaths.Add(ApplyTo.PortVisa, "epassport_ys_pv");
            DicPxlPaths.Add(ApplyTo.SocialSecurity, "epassport_ys_sb");
            DicPxlPaths.Add(ApplyTo.DrivingLicence, "epassport_ys_jsz");
        }

        public TabPageApplyOption()
        {
            InitDic();
            InitializeComponent();         
        }
     
        public override void InitCtrls()
        {
            PhotoApplyOption option = Configs.PhoApplyOption;
            comboBoxOrigPhotoFormat.SelectedIndex = (int)option.SourceImageFormat;
            comboBoxDestPhotoFormat.SelectedIndex = (int)option.DestImageFormat;
            comboBoxApplyType.SelectedIndex = (int)option.ApplyType;
            textBoxPxlFltPath.Text = option.PxlFltPath;
        }

        public override bool UpdateData()
        {
            PhotoApplyOption option = Configs.PhoApplyOption;
            option.ApplyType = (ApplyTo)comboBoxApplyType.SelectedIndex;
            option.DestImageFormat = (ImageFormats)comboBoxDestPhotoFormat.SelectedIndex;
            option.SourceImageFormat = (ImageFormats)comboBoxOrigPhotoFormat.SelectedIndex;
            option.PxlFltPath = textBoxPxlFltPath.Text;
            Configs.PhoApplyOption = option;
            return true;
        }

        private void comboBoxApplyType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ApplyTo applyType = (ApplyTo)comboBoxApplyType.SelectedIndex;
            textBoxPxlFltPath.Text = DicPxlPaths[applyType];
            //option.PxlFltPath = textBoxPxlFltPath.Text;
        }
    }
}
